/*!
 * @file        apm32f00x_int.h
 *
 * @brief       This file contains the headers of the interrupt handlers
 *
 * @version     V1.0.0
 *
 * @date        2019-11-4
 *
 */
#ifndef APM32F00X_INT_H
#define APM32F00X_INT_H

#include "apm32f00x.h"


/** @addtogroup BootLoader
  @{
*/

/** @defgroup BootLoader_INT_Macros INT_Macros
  @{
*/

/* application 1 interrupt vector address */

#define 		USER_APP1_ADDRESS           							 (uint32_t)0x2000
#define     APP1_NonMaskableInt_IRQn_APP_ADDR          (uint32_t) (USER_APP1_ADDRESS+0x08)    /*!< 2 Non Maskable Interrupt                                */
#define     APP1_HardFault_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0x0C)    /*!< 3 Cortex-M0 Hard Fault Interrupt                        */
#define     APP1_SVC_IRQn_APP_ADDR                     (uint32_t) (USER_APP1_ADDRESS+0x2C)    /*!< 11 Cortex-M0 SV Call Interrupt                          */
#define     APP1_PendSV_IRQn_APP_ADDR                  (uint32_t) (USER_APP1_ADDRESS+0x38)    /*!< 14 Cortex-M0 Pend SV Interrupt                          */
#define     APP1_SysTick_IRQn_APP_ADDR                 (uint32_t) (USER_APP1_ADDRESS+0x3C)    /*!< 15 Cortex-M0 System Tick Interrupt                      */

#define     APP1_WUPT_IRQn_APP_ADDR                    (uint32_t) (USER_APP1_ADDRESS+0x44)    /*!< Wakeup timer                                            */
#define     APP1_RCM_IRQn_APP_ADDR                     (uint32_t) (USER_APP1_ADDRESS+0x48)    /*!< Clock controller interrupt                              */
#define     APP1_EINTA_IRQn_APP_ADDR                   (uint32_t) (USER_APP1_ADDRESS+0x4C)    /*!< Port A external interrupts                              */
#define     APP1_EINTB_IRQn_APP_ADDR                   (uint32_t) (USER_APP1_ADDRESS+0x50)    /*!< Port B external interrupts                              */
#define     APP1_EINTC_IRQn_APP_ADDR                   (uint32_t) (USER_APP1_ADDRESS+0x54)    /*!< Port C external interrupts                              */
#define     APP1_EINTD_IRQn_APP_ADDR                   (uint32_t) (USER_APP1_ADDRESS+0x58)    /*!< Port D external interrupts                              */

#define     APP1_SPI_IRQn_APP_ADDR                     (uint32_t) (USER_APP1_ADDRESS+0x68)    /*!< SPI Interrupt                                           */
#define     APP1_TMR1_UT_IRQn_APP_ADDR                 (uint32_t) (USER_APP1_ADDRESS+0x6C)    /*!< TIMER1 update/overflow/underflow/trigger/break interrupt  */
#define     APP1_TMR1_CC_IRQn_APP_ADDR                 (uint32_t) (USER_APP1_ADDRESS+0x70)    /*!< TIMER1 capture/compare interrupt                          */
#define     APP1_TMR2_UO_IRQn_APP_ADDR                 (uint32_t) (USER_APP1_ADDRESS+0x74)    /*!< TIMER2 update /overflow interrupt                         */
#define     APP1_TMR2_CC_IRQn_APP_ADDR                 (uint32_t) (USER_APP1_ADDRESS+0x78)    /*!< TIMER2 capture/compare interrupt                          */
#define     APP1_USART1_TX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0x84)    /*!< USART1 TX interrupt                                      */
#define     APP1_USART1_RX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0x88)    /*!< USART1 RX interrupt                                      */
#define     APP1_IIC_IRQn_APP_ADDR                     (uint32_t) (USER_APP1_ADDRESS+0x8C)    /*!< I2C Interrupt                                           */
#define     APP1_ADC_IRQn_APP_ADDR                     (uint32_t) (USER_APP1_ADDRESS+0x98)    /*!< ADC interrupt                                          */
#define     APP1_TMR4_IRQn_APP_ADDR                    (uint32_t) (USER_APP1_ADDRESS+0x9C)    /*!< TIMER4 update /overflow interrupt                         */
#define     APP1_FLASH_IRQn_APP_ADDR                   (uint32_t) (USER_APP1_ADDRESS+0xA0)    /*!< Flash interrupt                                         */
#define     APP1_USART3_TX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0xA4)    /*!< USART3 TX interrupt                                      */
#define     APP1_USART3_RX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0xA8)    /*!< USART3 RX interrupt                                      */
#define     APP1_USART2_TX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0xAC)    /*!< USART2 TX interrupt                                      */
#define     APP1_USART2_RX_IRQn_APP_ADDR               (uint32_t) (USER_APP1_ADDRESS+0xB0)    /*!< USART2 RX interrupt                                      */
#define     APP1_TMR1A_UT_IRQn_APP_ADDR                (uint32_t) (USER_APP1_ADDRESS+0xB4)    /*!< TIMER1A update/overflow/underflow/trigger/break interrupt */
#define     APP1_TMR1A_CC_IRQn_APP_ADDR                (uint32_t) (USER_APP1_ADDRESS+0xB8)    /*!< TIMER1A capture/compare interrupt                         */

/**
 * @brief   INTERRUPT_VECTOR_STATE_T
 */
typedef enum
{
    IAP_INTERRUPT_VECTOR    = ((uint8_t)0), //!< IAP interrupt vector
    APP1_INTERRUPT_VECTOR   = ((uint8_t)1), //!< APP1 interrupt vector
} INTERRUPT_VECTOR_STATE_T;

/**@} end of group BootLoader_INT_Enumeration */

/** @defgroup BootLoader_INT_Variables INT_Variables
  @{
*/

extern uint32_t FLASH_interrupt_vector;

/**@} end of group BootLoader_INT_Variables */

/** @defgroup BootLoader_INT_Functions INT_Functions
  @{
*/

void NMI_Handler(void);
void HardFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#endif

